package myservice.android.utilities;

import java.util.Comparator;

public class PersonComparator implements Comparator<Record> {
	
	public static final int RECENTLY_NOT_VISITED = 1;
	public static final int RECENTLY_VISITED = 2;
	
	private int mode = 0;
	
	public PersonComparator(int mode) {
		super();
		this.mode = mode;
	}

	@Override
	public int compare(Record rec1, Record rec2) {	
		
		Long date1 = rec1.lastVisited;
		Long date2 = rec2.lastVisited;
		
		int result;
		
		if (date1 < date2)
			result = -1;
		else if (date1 > date2)
			result = 1;
		else
			result = 0;
		
		if (mode == RECENTLY_VISITED)
			result = result * -1;
					
		return result;
		
	}

}
